package com.meihua.shellapp.common;

import android.text.TextUtils;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.meihua.shellapp.utils.MD5Utils;

import java.util.Map;

/**
 * Created by ${zhangyuanchao} on 2017/9/30.
 */

public class NetHelper {
    /*post 请求*/
    public static void post(String url, Map<String,String> params,HttpCallBack callBack,boolean isDecode){
        if(TextUtils.isEmpty(url)){
            throw new IllegalArgumentException("params is null");
        }
        /*加密*/
        if(isDecode) {
            String time = (System.currentTimeMillis() + "").substring(0, 10);
            String key = MD5Utils.encode(MD5Utils.encode(time) + "meihua-insurance");
            params.put("request_time",time);
            params.put("key",key);
        }
        OkGo.<String>post(url).params(params).execute(callBack);
    }
    /*回调*/
    public static abstract class HttpCallBack extends StringCallback{
    }
}
